package zzz.javademo;

import java.sql.*;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by 隼 on 2016/12/9.
 */
public class php2 {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection com= DriverManager.getConnection("jdbc:mysql://localhost:3306/ict2", "root", "root");
            Connection comt= DriverManager.getConnection("jdbc:mysql://localhost:3306/ict2", "root", "root");
            //获取传输器对象
            Statement statement=com.createStatement();
            Statement stat=comt.createStatement();

            ResultSet rs=statement.executeQuery("SELECT id FROM lcchildren WHERE eid = 11 ");
            while(rs.next()){
               int id=rs.getInt("id");
                java.util.Date date=new java.util.Date();

                //生成日期对象
                java.util.Date current_date = new java.util.Date();
                //设置日期格式化样式为：yyyy-MM-dd
                SimpleDateFormat SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                //格式化当前日期
                SimpleDateFormat.format(current_date.getTime());
                //输出测试一下
                //System.out.println("当前的系统日期为：" + SimpleDateFormat.format(current_date.getTime()));


                String srt=" INSERT INTO sd_childrule ( childuid,ruleid,createtime) VALUES("+id+",1,'"+SimpleDateFormat.format(current_date.getTime())+"')";
                System.out.println(id);
                System.out.println(srt);
                int i=stat.executeUpdate(srt);
               // System.out.println(str);
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        //获取数据库连接



    }
}
